// @include "../../../scripts/spket.js"

testAPIHello = {
	name: function() {
		return "API Hello Test";
	},
	testSay: function() {
		var params = { name: 'Pei Xiaoxing' };
		var expected = 'Hello, Pei Xiaoxing!';
		var actual = api.hello.say(params);
		Assert.assertEquals(expected, actual);
	},
	testUpload: function() {
		var _req = {
			getHeader: function(name) {
				if (name === "Content-Length") {
					return _size;
				}
			}
		},
		_name = "Filedata", _size = 10,
		_dest, uploadCalled = 0;

		panda.fileName = function(req, name) {
			if (req === _req && name === _name) {
				return "fileName";
			}
		};

		panda.upload = function(req, name, dest) {
			if (req === _req && name === _name) {
				_dest = dest;
				++uploadCalled;
				return _size;
			}
		};

		var actual = api.hello.upload(undefined, _req);

		Assert.assertEquals(_dest, "upload/" + actual.name);
		Assert.assertEquals(_size, actual.size, 0);
		Assert.assertEquals(1, uploadCalled, 0);
	},
	testDownload: function() {
		var _req = {},
			_srcName = "SomeFile",
			_src = "1234-" + _srcName, 
			downloadCalled = 0;

		panda.download = function(req, res, name, src) {
			if (req === _req && name === _srcName
					&& src === "upload/" + _src) {
				++downloadCalled;
			}
		};

		api.hello.download({name: _src}, _req);
		Assert.assertEquals(1, downloadCalled, 0);
	}
};
